using System;
using System.Collections;
using System.Collections.Generic;
using cfg.level;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;

namespace QFramework.Monk
{
    public class SkillUIItem : MonoBehaviour
    {
        private Image mIcon;
        private  Text mLv;

        private void Awake()
        {
            if (mIcon==null)
            {
                mIcon = transform.Find("Icon").GetComponent<Image>();
            }
            if (mLv == null)
            {
                mLv = transform.Find("Lv").GetComponent<Text>();
            }
        }

        public void RefreshLv(SkillType skillType)
        {
            var lv = 0;
            if (Player.Default)
            {
                switch (skillType)
                {
                    case SkillType.Attack:
                        lv = AppStart.attackSkillLv.Value;
                        break;
                    case SkillType.AttackCD:
                        lv = AppStart.attackCdSkillLv.Value;
                        break;
                    case SkillType.Speed:
                        lv = AppStart.speedSkillLv.Value ;
                        break;
                    case SkillType.Axe:
                        lv = Player.Default.SimpleAxe.Level;
                        break;
                    case SkillType.Sword:
                        lv = Player.Default.SimpleSword.Level;
                        break;
                    case SkillType.Knife:
                        lv =Player.Default.SimpleKnife.Level;
                        break;
                    case SkillType.Shield:
                        lv = Player.Default.SimpleCircle.Level;
                        break;
                    case  SkillType.Ball:
                       lv =  Player.Default.SimpleBall.Level;
                        break;
                
                }
            }

            if (mLv == null)
            {
                mLv = transform.Find("Lv").GetComponent<Text>();
            }
            mLv.text = "Lv."+lv;
        }

        public void SetImage(Sprite sprite)
        {
            if (mIcon==null)
            {
                mIcon = transform.Find("Icon").GetComponent<Image>();
            }
            mIcon.sprite = sprite;
        }
    }
    
}

